/**
 * 获取分组数据的最近出院日期
 */
function getMaxDate()
{
	$.post(contextPath+"/CaseAnalysis/getMaxDate.dhc").done(function(result){
    	var maxDate = result.data;
    	if(null!=maxDate&&""!=maxDate)
		{
    		var year = maxDate.split("-")[0];
    		var month = maxDate.split("-")[1];
    		$('#'+tabId+' input#startDate').val(year+"-"+month+"-01");//开始时间
    		$('#'+tabId+' input#endDate').val(maxDate);//结束时间
		}
    	else
		{
    		var now = GetDateStr(0,"d");
    		var year = now.split("-")[0];
    		var month = now.split("-")[1];
    		$('#'+tabId+' input#startDate').val(year+"-"+month+"-01");//开始时间
    		$('#'+tabId+' input#endDate').val(now);//结束时间
		}
    	loadConditionData();
	});
}

//自动点击查询
function loadConditionData()//加载完日期之后加载指定条件下的数据
{
	$('#'+tabId+' #search_png').click();
}

//病例信息总体情况 页面上层的汇总信息
/**
 * monitorType 页面所处的层次 depGroup dep ward clinic
 */
function caseInfoTotal(monitorType)
{
	$.post(contextPath+'/CaseAnalysis/loadTotalHspOutCaseInfo.dhc',{
	'monitorType':monitorType,
	'pardepgroupCode':paramTabPage[tabId].depGroupCode,
	'pardepCode':paramTabPage[tabId].depCode,
	'parwardCode':paramTabPage[tabId].wardCode,
	'dateFrom':paramTabPage[tabId].dateFrom,
	'dateTo':paramTabPage[tabId].dateTo
	}).done(function(result){
		var str="";
		str+='	<table id="totalOutCase-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
		str+='		<thead> ';
		str+='			<tr role="row"> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1"></th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院病例数</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组病例数</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">未入组病例数</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">大于60天病例数</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组率(%)</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">死亡病例数</th> ';
		str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">死亡率(%)</th> ';
		str+='			</tr> ';
		str+='		</thead> ';
		str+='		<tbody></tbody> ';
		str+='	</table> ';
		$('#'+tabId+' #totalOutCase').html(str);
		var columns = [
		               {
		            	   "data": 'count',
		            	   "sWidth":50,
		            	   "render": function(obj, type, full) {
		            		   return "病例数";
		            	   }
		               },
		               {
		            	   "data": 'totalCaseCnt'
		               },
		               {
		            	   "data": 'InCaseCnt'
		               },
		               {
		            	   "data": 'notInCaseCnt',
		            	   "render": function(obj, type, full) {
		            		   return "<a href = \"javascript:caseData('"+monitorType+"','notin','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.notInCaseCnt+"</a>";
		            	   }
		               },
		               {
		            	   "data": 'over60Cnt',
		            	   "render": function(obj, type, full) {
		            		   return "<a href = \"javascript:caseData('"+monitorType+"','over60','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.over60Cnt+"</a>";
		            	   }
		               },
		               {"data": 'InRatio'},
		               {
		            	   "data": 'deadCnt',
		            	   "render": function(obj, type, full) {
		            		   return "<a href = \"javascript:caseData('"+monitorType+"','dead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.deadCnt+"</a>";
		            	   }
		               },
		               {"data": 'deadRatio'}
		               ];
		var data = result.data;
		$("#"+tabId+" #totalOutCase-CaseAnalysis").caseAnalysisDataTable(columns, data, 0, 0, 0, 0,0);
	});
}

/**
 * 入组病例
 * @param monitorType 科室线 层级
 * @param caseType 病例类型
 * @param depGroup 科室组代码
 * @param dep 科室代码
 * @param ward 病区代码
 * @param clinic 主诊组代码
 * @param mdc mdc代码
 */
function caseData(monitorType,caseType,depGroup,dep,ward,clinic,mdc)
{
	$("#modalcq .close").click();
	//请求数据传给页面
	$.post(contextPath+'/CaseAnalysis/caseData.dhc',{
	'monitorType':monitorType,
	'type1':caseType,//病例类型
	'dateFrom':paramTabPage[tabId].dateFrom,
	'dateTo':paramTabPage[tabId].dateTo,
	'pardepgroupCode':depGroup,
	'pardepCode':dep,
	'parwardCode':ward,
	'pargroupName':clinic,
	'parmdcCode':mdc
	}).done(function(result){
		var pageId = monitorType+caseType+depGroup+dep+ward+clinic+mdc+"caselist";
		if(caseType == "notin"||caseType == "over60")
		{
			openTab('/pages/yizheng/fenxi/notincaselist.jsp', '病例明细',pageId,pageId,{data:result.data});
		}
		else
		{
			openTab('/pages/yizheng/fenxi/caselist.jsp', '病例明细',pageId,pageId,{data:result.data});
		}
	});
	
}
/**
 * 各死亡风险组入组病例统计表 页面上层汇总 各风险等级汇总
 * monitorType 页面所处的层次 depGroup dep ward clinic
 */
function caseRiskLevelTotal(monitorType)
{
	$.post(contextPath+'/CaseAnalysis/loadTotalHspRiskGroupInfo.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			str+='	<table id="totalRisk-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1"></th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">零死亡组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">低风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">中低风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">中高风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">高风险组</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #totalRisk').html(str);
			var columns = [
			               {
			            	   "data": 'title',
			            	   "sWidth":50
			               },
			               {
			            	   "data": 'zero',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==1){
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','zerodead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.zero+"</a>";
			            		   }
			            		   return  full.zero ;
                  				 }
			               },
			               {
			            	   "data": 'low',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==1){
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','lowdead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.low+"</a>";
			            		   }
			            		   return  full.low ;
                  				 }
			               },
			               {
			            	   "data": 'midlow',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==1){
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','midlowdead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.midlow+"</a>";
			            		   }
			            		   return  full.midlow ;
                  				 }
			               },
			               {
			            	   "data": 'midhigh',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==1){
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','midhighdead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.midhigh+"</a>";
			            		   }
			            		   return  full.midhigh ;
                  				 }
			               },
			               {
			            	   "data": 'high',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==1){
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','highdead','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.high+"</a>";
			            		   }
			            		   return  full.high ;
                  				 }
			               }];
			var data = result.data;
			$("#"+tabId+" #totalRisk-CaseAnalysis").caseAnalysisDataTable(columns, data, 0, 0, 0, 0,0);
		});
}
/**
 * 未入组原因统计表  页面上层未入组原因汇总
 * monitorType 页面所处的层次 depGroup dep ward clinic
 */
function caseNotInGroupTotal(monitorType)
{

	$.post(contextPath+'/CaseAnalysis/loadTotalHspNotInInfo.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			str+='	<table id="totalNotIn-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1"></th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">手术/操作与诊断不符</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">费用/住院日异常</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">缺少主要诊断</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要诊断有误</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主诊断规范问题或新生儿年龄/体重问题</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">其他</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #totalNotIn').html(str);
			var columns = [
			               {
			            	   "data": 'title',
			            	   "sWidth":50
			               },
			               {
			            	   "data": 'diag_n_m_oper',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.diag_n_m_oper>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','1','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.diag_n_m_oper+"</a>";
			            		   }
			            		   return  full.diag_n_m_oper ;
                  				 }
			               },
			               {
			            	   "data": 'fee_day_err',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.fee_day_err>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','2','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.fee_day_err+"</a>";
			            		   }
			            		   return  full.fee_day_err ;
                  				 }
			               },
			               {
			            	   "data": 'lessdiag',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.lessdiag>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','3','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.lessdiag+"</a>";
			            		   }
			            		   return  full.lessdiag ;
                  				 }
			               },
			               {
			            	   "data": 'diagerr',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.diagerr>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','4','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.diagerr+"</a>";
			            		   }
			            		   return  full.diagerr ;
                  				 }
			               },
			               {
			            	   "data": 'babyerr',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.babyerr>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','5','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.babyerr+"</a>";
			            		   }
			            		   return  full.babyerr ;
                  				 }
			               },
			               {
			            	   "data": 'other',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==0&&full.other>0){
			            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].monitorType+"','6','"+paramTabPage[tabId].depGroupCode+"','"+paramTabPage[tabId].depCode+"','"+paramTabPage[tabId].wardCode+"')\">"+full.other+"</a>";
			            		   }
			            		   return  full.other ;
                  				 }
			               }];
			var data = result.data;
			$("#"+tabId+" #totalNotIn-CaseAnalysis").caseAnalysisDataTable(columns, data, 0, 0, 0, 0,0);
		});

}

/**
 * 未入组病例
 * @param monitorType 科室线 层级
 * @param notInType 未入组病例类型
 * @param depGroup 科室组代码
 * @param dep 科室代码
 * @param ward 病区代码
 * @param clinic 主诊组代码
 */
function notInCaseData(monitorType,notInType,depGroup,dep,ward,clinic)
{
	//请求数据传给页面
	$.post(contextPath+'/CaseAnalysis/CaseData.dhc',{
	'monitorType':monitorType,
	'type1':notInType,// 未入组病例类型
	'dateFrom':paramTabPage[tabId].dateFrom,
	'dateTo':paramTabPage[tabId].dateTo,
	'pardepgroupCode':depGroup,
	'pardepCode':dep,
	'parwardCode':ward,
	'pargroupName':clinic
	}).done(function(result){
		var pageId = monitorType+notInType+depGroup+dep+ward+clinic+"notincaselist";
		openTab('/pages/yizheng/fenxi/notincaselist.jsp', '病例明细',pageId,pageId,{data:result.data});
	});
}

/**
 * 加载病例数诊断数手术数
 * monitorType 页面所处的层次 depGroup dep ward clinic
 */
function loadDiagOperCnt(monitorType)
{
	var title = getTitle(monitorType);
	$.post(contextPath+'/CaseAnalysis/loadMedicalRecordDataItem.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var data = result.data;
			var l = data.length;
			var str="";
			str+='	<table id="medicalRecordTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">诊断数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">手术数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #medicalRecordTable').html(str);
			var columns = [
			               {"data": 'tname',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
			               {"data": 'allcnt'},
			               {"data": 'diagcnt'},
			               {"data": 'opecnt'},
			               {
			            	   "data": 'operation',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
			            			   switch(paramTabPage[tabId].monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = paramTabPage[tabId].depGroupCode;
			            				   break;
			            			   case "dep":
			            				   dep = paramTabPage[tabId].depCode;
			            				   break;
			            			   case "ward":
			            				   ward = paramTabPage[tabId].wardCode;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:diagOperCntTrend('"+paramTabPage[tabId].previous+"','"+depgroup+"','"+dep+"','"+ward+"','','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
			            		   }
			            		   else
		            			   {
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
		            				   var clinic = "";
			            			   switch(monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = full.code;
			            				   break;
			            			   case "dep":
			            				   dep = full.code;
			            				   break;
			            			   case "ward":
			            				   ward = full.code;
			            				   break;
			            			   case "clinic":
			            				   if(paramTabPage[tabId].previous=='dep')
		            					   {
			            					   dep = paramTabPage[tabId].depCode;
		            					   }
			            				   else
		            					   {
			            					   ward = paramTabPage[tabId].wardCode;
		            					   }
			            				   clinic = full.code;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:diagOperCntTrend('"+monitorType+"','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
		            			   }
                  				 }
			               }];
			$("#"+tabId+" #medicalRecordTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 1,4,{id:['mr_OutCaseCntChart','mr_DiagnosisCntChart','mr_OperationCntChart'],nameCode:'name',field:['allcnt','diagcnt','opecnt'],title:['出院病例数分布图','诊断数分布图','手术数分布图'],ignore:true});
		});
}
/**
 * 判断是否有下一层
 * @param monitorType 取值 depGroup dep ward clinic
 * @returns {Boolean}
 */
function toNextLayerBool(monitorType)
{
	var bool = false;
	switch(monitorType)
	{
	case "depGroup":
		if(commonLayerConfig.length>=4&&(commonLayerConfig[1]=='1'||commonLayerConfig[2]=='1'))
		{bool = true;}
		break;
	case "dep":
		if(commonLayerConfig.length>=4&&(commonLayerConfig[2]=='1'||commonLayerConfig[3]=='1'))
		{bool = true;}
		break;
	case "ward":
		if(commonLayerConfig.length>=4&&commonLayerConfig[3]=='1')
		{bool = true;}
		break;
	}
	return bool;	
}
/**
 * 跳往下一个层级
 * monitorType 页面所处的层次 depGroup dep ward clinic
 * code某一层级的代码
 * name某一层级的名称
 */
function toNextLayerCaseAnalysis(monitorType,code,name)
{

	var param = jQuery.extend(true,{},paramTabPage[tabId]);//参数
	param.previous = monitorType;//指示当前的层次
	var destUrl = "";
	var pageId = "";
	switch(monitorType)
	{
	case "depGroup":
		param.depGroupCode = code;
		param.depGroupName = name;
		if(commonLayerConfig.length>=4)
		{
			if(commonLayerConfig[1]=='1')
			{
				destUrl = "/pages/yizheng/fenxi/depCaseAnalysis.jsp";
				pageId = code+"depGroupCaseAnalysis_To_Dep";
			}
			else if(commonLayerConfig[2]=='1')
			{
				pageId = code+"depGroupCaseAnalysis_To_Ward";
				destUrl = "/pages/yizheng/fenxi/wardCaseAnalysis.jsp";
			}
		}
		break;
	case "dep":
		param.depCode = code;
		param.depName = name;
		if(commonLayerConfig.length>=4)
		{
			if(commonLayerConfig[2]=='1')
			{
				destUrl = "/pages/yizheng/fenxi/wardCaseAnalysis.jsp";
				pageId = code+"depCaseAnalysis_To_Ward";
			}
			else if(commonLayerConfig[3]=='1')
			{
				pageId = code+"depCaseAnalysis_To_Clinic";
				destUrl = "/pages/yizheng/fenxi/clinicCaseAnalysis.jsp";
			}
		}
		break;
	case "ward":
		param.wardCode = code;
		param.wardName = name;
		if(commonLayerConfig.length>=4)
		{
			if(commonLayerConfig[3]=='1')
			{
				destUrl = "/pages/yizheng/fenxi/clinicCaseAnalysis.jsp";
				pageId = code+"wardCaseAnalysis_To_Clinic";
			}
		}
		break;
	}
	if(destUrl!="")
	{
		openTab(destUrl, name+"病例分析",pageId, pageId,param);
	}	
}
/**
 * 病例数 诊断数  手术数 趋势
 * @param monitorType =>depGroup dep ward clinic
 * @param depGroup 
 * @param dep
 * @param ward
 * @param clinic
 * @param name
 */
function diagOperCntTrend(monitorType,depGroup,dep,ward,clinic,name)
{
	 $.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html(name+"病案首页数据项趋势图");
			dialog.modal({
				keyboard: false
			}).on({
				'hidden.bs.modal' : function(){
					$(this).remove();
				},
				'shown.bs.modal' : function(){
					dialog.find(".modal-body").empty();
					var trendStr = "";
					trendStr += "<div class='tab-content'>";
					trendStr += "	<div role='tabpanel' class='tab-pane active'>";
					trendStr += "		<div class='paddingd10'>";
					trendStr += "			<ul class='nav nav-tabs tabconulcq' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_OutCaseCnt_Trend' role='tab' data-toggle='tab'>出院病例数</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_DiagnosisCnt_Trend' role='tab' data-toggle='tab'>诊断数</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_OperationCnt_Trend' role='tab' data-toggle='tab'>手术数</a></li>";
					trendStr += "			</ul>";
					trendStr += "		</div>";
					trendStr += "	</div>";
					trendStr += "	<div class='clearfix'></div>";
					trendStr += "	<div class='tab-content'>";
					trendStr += "		<div role='tabpanel' class='tab-pane active' id='mr_OutCaseCnt_Trend'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_OutCaseCnt_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_OutCaseCnt_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='mr_OutCaseCnt_Trend_M'>";
					trendStr += "					<div id='mr_OutCaseCnt_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='mr_OutCaseCnt_Trend_Y'>";
					trendStr += "					<div id='mr_OutCaseCnt_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "		<div role='tabpanel' class='tab-pane' id='mr_DiagnosisCnt_Trend'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_DiagnosisCnt_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_DiagnosisCnt_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='mr_DiagnosisCnt_Trend_M'>";
					trendStr += "					<div id='mr_DiagnosisCnt_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='mr_DiagnosisCnt_Trend_Y'>";
					trendStr += "					<div id='mr_DiagnosisCnt_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "		<div role='tabpanel' class='tab-pane' id='mr_OperationCnt_Trend'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_OperationCnt_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_OperationCnt_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='mr_OperationCnt_Trend_M'>";
					trendStr += "					<div id='mr_OperationCnt_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='mr_OperationCnt_Trend_Y'>";
					trendStr += "					<div id='mr_OperationCnt_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "	</div>";
					trendStr += "</div>";
					dialog.find(".modal-body").append(trendStr);
					var dateFrom = $('#'+tabId+' input#startDate').val();
					var dateTo = $('#'+tabId+' input#endDate').val();
					//出院病例趋势图
					$.post(contextPath+'/CaseAnalysis/mrDataItemTrend.dhc',{
					'monitorType':monitorType,
					'type1':'outcase',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){
						var year = dateFrom.substr(0,4);
						var caseCntlines = [];
						var caseCntlineT = {"code": "QuotaValue", "desc": year+"年", "data":[]};
						var caseCntlineL = {"code": "QuotaValue", "desc": (year-1)+"年", "data":[]};
						caseCntlines.push(caseCntlineT);
						caseCntlines.push(caseCntlineL);
						
						//病例数
						var caseCntdatas = [];
						caseCntdatas.push(result.data.monthCntT);
						caseCntdatas.push(result.data.monthCntL);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_OutCaseCnt_Trend_M_Chart"), caseCntlines, caseCntdatas, name+"出院病例数趋势图-月度",'',chartParams);
						
						var caseCntlines_Y = [{"code": "QuotaValue", "desc": "年度", "data":[]}];
						var caseCntdatas_Y = [];
						caseCntdatas_Y.push(result.data.yearCnt);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_OutCaseCnt_Trend_Y_Chart"), caseCntlines_Y, caseCntdatas_Y, name+"出院病例数趋势图-年度",'',chartParams);
					});
					//诊断数趋势图
					$.post(contextPath+'/CaseAnalysis/mrDataItemTrend.dhc',{
					'monitorType':monitorType,
					'type1':'diagnosis',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){
						var year = dateFrom.substr(0,4);
						var diagCntlines = [];
						var diagCntdataT = {"code": "QuotaValue", "desc": year+"年", "data":[]};
						var diagCntdataL = {"code": "QuotaValue", "desc": (year-1)+"年", "data":[]};
						diagCntlines.push(diagCntdataT);
						diagCntlines.push(diagCntdataL);
						
						//诊断数
						var diagCntdatas = [];
						diagCntdatas.push(result.data.monthCntT);
						diagCntdatas.push(result.data.monthCntL);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_DiagnosisCnt_Trend_M_Chart"), diagCntlines, diagCntdatas, name+"诊断数趋势图-月度",'',chartParams);
						
						var diagCntlines_Y = [{"code": "QuotaValue", "desc": "年度", "data":[]}];
						var diagCntdatas_Y = [];
						diagCntdatas_Y.push(result.data.yearCnt);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_DiagnosisCnt_Trend_Y_Chart"), diagCntlines_Y, diagCntdatas_Y, name+"诊断例数趋势图-年度",'',chartParams);
					});
					//手术数趋势图
					$.post(contextPath+'/CaseAnalysis/mrDataItemTrend.dhc',{
					'monitorType':monitorType,
					'type1':'operation',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){
						var year = dateFrom.substr(0,4);
						var operCntlines = [];
						var operCntlineT = {"code": "QuotaValue", "desc": year+"年", "data":[]};
						var operCntlineL = {"code": "QuotaValue", "desc": (year-1)+"年", "data":[]};
						operCntlines.push(operCntlineT);
						operCntlines.push(operCntlineL);
						
						//手术数
						var operCntdatas = [];
						operCntdatas.push(result.data.monthCntT);
						operCntdatas.push(result.data.monthCntL);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_OperationCnt_Trend_M_Chart"), operCntlines, operCntdatas, name+"手术数趋势图-月度",'',chartParams);
						
						var operCntlines_Y = [{"code": "QuotaValue", "desc": "年度", "data":[]}];
						var operCntdatas_Y = [];
						operCntdatas_Y.push(result.data.yearCnt);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #mr_OperationCnt_Trend_Y_Chart"), operCntlines_Y, operCntdatas_Y, name+"手术数趋势图-年度",'',chartParams);
					});
				}
			});
			
			
	 });

}
/**
 * 获取对应层次的名字
 * @param monitorType =>depGroup dep ward clinic
 * @returns {String}
 */
function getTitle(monitorType)
{
	var title = "";
	switch(monitorType)
	{
	case "depGroup":
		title = "科室组";
		break;
	case "dep":
		title = "科室";
		break;
	case "ward":
		title = "病区"
		break;
	case "clinic":
		title = "主诊组";
		break;
	}
	return title;
}
/**
 * 加载缺少年龄和诊断的病例信息
 * @param monitorType  =>depGroup dep ward clinic
 */
function loadLessAgeDiag(monitorType)
{
	var title = getTitle(monitorType);
	$.post(contextPath+'/CaseAnalysis/loadDataItemEffectDrg.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			var data = result.data;
			var l = data.length;
			str+='	<table id="effectDrggroupTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="2" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="2" colspan="1">出院病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">无法获取年龄病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">无法获取主要诊断病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="2" colspan="1">操作</th> ';
			str+='			</tr> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">本'+title+'内占比(%)</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">本'+title+'内占比(%)</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #effectDrggroupTable').html(str);
			var columns = [
			               {"data": 'name1',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
			               {"data": 'allcnt'},
			               {"data": 'lessagecnt'},
			               {"data": 'lessageper'},
			               {"data": 'lessdiagcnt'},
			               {"data": 'lessdiagper'},
			               {"data": 'operation',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
			            			   switch(paramTabPage[tabId].monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = paramTabPage[tabId].depGroupCode;
			            				   break;
			            			   case "dep":
			            				   dep = paramTabPage[tabId].depCode;
			            				   break;
			            			   case "ward":
			            				   ward = paramTabPage[tabId].wardCode;
			            				   break;
			            			   }
			            			   
			            			   return "<a href = \"javascript:lessAgeDiagTrend('"+paramTabPage[tabId].previous+"','"+depgroup+"','"+dep+"','"+ward+"','','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
			            		   }
			            		   else
		            			   {
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
		            				   var clinic = "";
			            			   switch(monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = full.code;
			            				   break;
			            			   case "dep":
			            				   dep = full.code;
			            				   break;
			            			   case "ward":
			            				   ward = full.code;
			            				   break;
			            			   case "clinic":
			            				   if(paramTabPage[tabId].previous=='dep')
		            					   {
			            					   dep = paramTabPage[tabId].depCode;
		            					   }
			            				   else
		            					   {
			            					   ward = paramTabPage[tabId].wardCode;
		            					   }
			            				   clinic = full.code;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:lessAgeDiagTrend('"+monitorType+"','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
		            			   }
                  				 }
		            	   }];
			
			$("#"+tabId+" #effectDrggroupTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 1,6,{id:['mr_NoAgeCntChart','mr_NoMainDiagnosisCntChart'],nameCode:'name',field:['lessagecnt','lessdiagcnt'],title:['无年龄字段病例分布图','无主要诊断字段病例分布图'],ignore:true});
		});
}
/**
 * 缺少年龄诊断的趋势图
 * @param monitorType =>depGroup dep ward clinic
 * @param depGroup
 * @param dep
 * @param ward
 * @param clinic
 * @param name
 */
function lessAgeDiagTrend(monitorType,depGroup,dep,ward,clinic,name)
{
	 $.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html(name+"缺少年龄诊断病例统计");
			dialog.modal({
				keyboard: false
			}).on({
				'hidden.bs.modal' : function(){
					$(this).remove();
				},
				'shown.bs.modal' : function(){
					dialog.find(".modal-body").empty();
					var trendStr = "";
					trendStr += "<div class='tab-content'>";
					trendStr += "	<div role='tabpanel' class='tab-pane active'>";
					trendStr += "		<div class='paddingd10'>";
					trendStr += "			<ul class='nav nav-tabs tabconulcq' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_Less_Age_Trend' role='tab' data-toggle='tab'>无法获取年龄</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_Less_Diag_Trend' role='tab' data-toggle='tab'>无法获取诊断</a></li>";
					trendStr += "			</ul>";
					trendStr += "		</div>";
					trendStr += "	</div>";
					trendStr += "	<div class='clearfix'></div>";
					trendStr += "	<div class='tab-content'>";
					trendStr += "		<div role='tabpanel' class='tab-pane active' id='mr_Less_Age_Trend'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_Less_Age_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_Less_Age_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='mr_Less_Age_Trend_M'>";
					trendStr += "					<div id='mr_Less_Age_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='mr_Less_Age_Trend_Y'>";
					trendStr += "					<div id='mr_Less_Age_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "		<div role='tabpanel' class='tab-pane' id='mr_Less_Diag_Trend'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#mr_Less_Diag_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#mr_Less_Diag_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='mr_Less_Diag_Trend_M'>";
					trendStr += "					<div id='mr_Less_Diag_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='mr_Less_Diag_Trend_Y'>";
					trendStr += "					<div id='mr_Less_Diag_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "	</div>";
					trendStr += "</div>";
					dialog.find(".modal-body").append(trendStr);
					var dateTo = $('#'+tabId+' input#endDate').val();
					
					var thisYear = dateTo.substr(0,4);
					//缺少年龄的
					$.post(contextPath+'/CaseAnalysis/loadAgeDiagTrend.dhc',{
					'monitorType':monitorType,
					'type1':'lessAge',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){
						var data = result.data;
						var legendMonth = ["本年病例数","上年病例数","本年病例数占比","上年病例数占比"];
						var seriesMonth = [
						              {name:"本年病例数",type:'bar',clickable:false,data:data["thisYearMonth"]},
								      {name:"上年病例数",type:'bar',clickable:false,data:data["lastYearMonth"]},
								      {name:"本年病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["thisYearMonthRatio"]},
								      {name:"上年病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["lastYearMonthRatio"]}
								     ];
						var xAxisMonth = [{type : 'category',data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']}];
						var yAxis = [{type : 'value',name:'病例数'},{type:'value',name:'病例占比', axisLabel:{formatter:'{value} %'}}];
						var legendYear = ["病例数","病例数占比"];
						var seriesYear = [
								              {name:"病例数",type:'bar',clickable:false,data:data["last5Year"]},
										      {name:"病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["last5YearRatio"]}
										     ];
						var xAxisYearData = [];
						for(var i=thisYear-4;i<=thisYear;i++)
						{
							xAxisYearData.push(i+"年")
						}
						xAxisYear = [{type : 'category',data :xAxisYearData}];
						barLineMixChartBasic(dialog.find(".modal-body #mr_Less_Age_Trend_M_Chart"),legendMonth,seriesMonth,xAxisMonth,yAxis);
						barLineMixChartBasic(dialog.find(".modal-body #mr_Less_Age_Trend_Y_Chart"),legendYear,seriesYear,xAxisYear,yAxis);
					});
					//缺少主要诊断的
					$.post(contextPath+'/CaseAnalysis/loadAgeDiagTrend.dhc',{
					'monitorType':monitorType,
					'type1':'lessDiag',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){

						var data = result.data;
						var legendMonth = ["本年病例数","上年病例数","本年病例数占比","上年病例数占比"];
						var seriesMonth = [
						              {name:"本年病例数",type:'bar',clickable:false,data:data["thisYearMonth"]},
								      {name:"上年病例数",type:'bar',clickable:false,data:data["lastYearMonth"]},
								      {name:"本年病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["thisYearMonthRatio"]},
								      {name:"上年病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["lastYearMonthRatio"]}
								     ];
						var xAxisMonth = [{type : 'category',data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']}];
						var yAxis = [{type : 'value',name:'病例数'},{type:'value',name:'病例占比', axisLabel:{formatter:'{value} %'}}];
						var legendYear = ["病例数","病例数占比"];
						var seriesYear = [
								              {name:"病例数",type:'bar',clickable:false,data:data["last5Year"]},
										      {name:"病例数占比",type:'line',clickable:false,yAxisIndex: 1,data:data["last5YearRatio"]}
										     ];
						var xAxisYearData = [];
						for(var i=thisYear-4;i<=thisYear;i++)
						{
							xAxisYearData.push(i+"年")
						}
						xAxisYear = [{type : 'category',data :xAxisYearData}];
						barLineMixChartBasic(dialog.find(".modal-body #mr_Less_Diag_Trend_M_Chart"),legendMonth,seriesMonth,xAxisMonth,yAxis);
						barLineMixChartBasic(dialog.find(".modal-body #mr_Less_Diag_Trend_Y_Chart"),legendYear,seriesYear,xAxisYear,yAxis);
					
					});
				}
			});
	 });
}

/**
 * 加载各层次的病例信息
 * @param monitorType =>depGroup dep ward clinic
 */
function loadLayerCaseInfo(monitorType)
{
	var title = getTitle(monitorType);
	$.post(contextPath+'/CaseAnalysis/loadOutCaseTypeInfo.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var data = result.data;
			var l = data.length;
			var str="";
			str+='	<table id="outCaseDepGroupDistributeTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">大于60天病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">未入组病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组率(%)</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #outCaseDepGroupDistributeTable').html(str);
			var columns = [
			               {"data": 'name',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
			               {"data": 'allcnt'},
			               {"data": 'over60Cnt',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1)
		            			   {
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
			            			   switch(paramTabPage[tabId].monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = paramTabPage[tabId].depGroupCode;
			            				   break;
			            			   case "dep":
			            				   dep = paramTabPage[tabId].depCode;
			            				   break;
			            			   case "ward":
			            				   ward = paramTabPage[tabId].wardCode;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','over60','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.over60Cnt+"</a>";
		            			   }
			            		   else
		            			   {
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
		            				   var clinic = "";
			            			   switch(monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = full.code;
			            				   break;
			            			   case "dep":
			            				   dep = full.code;
			            				   break;
			            			   case "ward":
			            				   ward = full.code;
			            				   break;
			            			   case "clinic":
			            				   if(paramTabPage[tabId].previous=='dep')
		            					   {
			            					   dep = paramTabPage[tabId].depCode;
		            					   }
			            				   else
		            					   {
			            					   ward = paramTabPage[tabId].wardCode;
		            					   }
			            				   clinic = full.code;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:caseData('"+monitorType+"','over60','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.over60Cnt+"</a>";
		            			   }
		            		   }
			               },
			               {"data": 'notincasecnt'},
			               {"data": 'incasecnt'},
			               {"data": 'inRatio'}
			               ];
			
			$("#"+tabId+" #outCaseDepGroupDistributeTable-CaseAnalysis").caseAnalysisDataTable(columns, data,1, 0, 1, 1,0);
			var tmpdata = [];
			tmpdata.push({name:'大于60天病例数',value:data[l-1].over60Cnt});
			tmpdata.push({name:'未入组病例数',value:data[l-1].notincasecnt});
			tmpdata.push({name:'入组病例数',value:data[l-1].incasecnt});
			pieCharts($('#'+tabId+' #totalOutCaseChart'), tmpdata,'出院病例分布图', '',0,layerCaseInfoDistribute,'入组病例数',$('#'+tabId+' #outCaseDepGroupDistributeChart'),monitorType);
		});

}
/**
 * 出院病历信息的分布图
 */
var layerCaseInfoDistribute = function layerCaseInfoDistributeChart(monitorType,piece)
{
	$.post(contextPath+'/CaseAnalysis/outCaseDepGroupDistributeChart.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,
		'type2':piece,//该字段用于记录前一块饼图所选块的块名
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		
		}).done(function(result){
			var data = result.data;
			var dataLength = data.length;
			var outCaseDepGroupDistributeCnt = [];
			for(var i = 0;i<dataLength&&i<9;i++)
			{
				outCaseDepGroupDistributeCnt.push({name:data[i].name,value:data[i].cnt});
			}
			if(dataLength>9)
			{
				var otherCnt = 0;
				for(var i = 9;i<dataLength;i++)
				{
					otherCnt = otherCnt+data[i].cnt;
				}
				outCaseDepGroupDistributeCnt.push({name:'其他',value:otherCnt});
			}
			pieCharts($('#'+tabId+' #outCaseDepGroupDistributeChart'), outCaseDepGroupDistributeCnt, piece+'分布图', '');
		});
}

/**
 * 加载各层各风险等级的病例信息
 * @param monitorType =>depGroup dep ward clinic
 */
function loadLayerCaseRiskInfo(monitorType)
{
	var title = getTitle(monitorType);
	$.post(contextPath+'/CaseAnalysis/depGroupInGroupCase.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var data = result.data;
			var l = data.length;
			var str="";
			str+='	<table id="inGroupCaseDepGroupDistributeTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="2" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">无风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">低风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">中低风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">中高风险组</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="2">高风险组</th> ';
			str+='			</tr> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">死亡数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">死亡数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">死亡数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">治愈数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">入组数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">治愈数</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #inGroupCaseDepGroupDistributeTable').html(str);
			var columns = [
			               {"data": 'name',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
			               {"data": 'risk0casecnt'},
			               {"data": 'risk0deadcasecnt',
			            	   "render": function(obj, type, full){
			            		   if(full.risk0deadcasecnt>0)
		            			   {

				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','zerodead','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.risk0deadcasecnt+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','zerodead','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.risk0deadcasecnt+"</a>";
			            			   }
		            			   }
			            		   return full.risk0deadcasecnt;
		            		   }
		            	   },
			               {"data": 'risk1casecnt'},
			               {"data": 'risk1deadcasecnt',
			            	   "render": function(obj, type, full){
			            		   if(full.risk1deadcasecnt>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','lowdead','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.risk1deadcasecnt+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','lowdead','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.risk1deadcasecnt+"</a>";
			            			   }
		            			   }
			            		   return full.risk1deadcasecnt;
		            		   }
			               },
			               {"data": 'risk2casecnt'},
			               {"data": 'risk2deadcasecnt',
			            	   "render": function(obj, type, full){
			            		   if(full.risk2deadcasecnt>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','midlowdead','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.risk2deadcasecnt+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','midlowdead','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.risk2deadcasecnt+"</a>";
			            			   }
		            			   }
			            		   return full.risk2deadcasecnt;
		            		   }
			               },
			               {"data": 'risk3casecnt'},
			               {"data": 'risk3curecasecnt',
			            	   "render": function(obj, type, full){
			            		   if(full.risk3curecasecnt>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','midhighcure','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.risk3curecasecnt+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','midhighcure','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.risk3curecasecnt+"</a>";
			            			   }
		            			   }
			            		   return full.risk3curecasecnt;
		            		   }
			               },
			               {"data": 'risk4casecnt'},
			               {"data": 'risk4curecasecnt',
			            	   "render": function(obj, type, full){
			            		   if(full.risk4curecasecnt>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+paramTabPage[tabId].previous+"','highcure','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.risk4curecasecnt+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','highcure','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.risk4curecasecnt+"</a>";
			            			   }
		            			   }
			            		   return full.risk4curecasecnt;
		            		   }
			               }];
			
			$("#"+tabId+" #inGroupCaseDepGroupDistributeTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 1,0);
			
			var tmpdata = [];
			tmpdata.push({name:'无风险组',value:data[l-1].risk0casecnt});
			tmpdata.push({name:'低风险组',value:data[l-1].risk1casecnt});
			tmpdata.push({name:'中低风险组',value:data[l-1].risk2casecnt});
			tmpdata.push({name:'中高风险组',value:data[l-1].risk3casecnt});
			tmpdata.push({name:'高风险组',value:data[l-1].risk4casecnt});
			pieCharts($('#'+tabId+' #inGroupCaseChart'), tmpdata,'各风险组入组病例分布图', '',0,layerCaseRiskInfoDistribute,'无风险组',$('#'+tabId+' #inGroupCaseDepGroupDistributeChart'),monitorType);
		});

}
/**
 * 各风险等级病例的分布图
 */
var layerCaseRiskInfoDistribute = function layerCaseRiskInfoDistributeChart(monitorType,piece)
{
	$.post(contextPath+'/CaseAnalysis/inGroupCaseDepGroupDistributeChart.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,
		'type2':piece,//该字段用于记录前一块饼图所选块的块名
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){

			var data = result.data;
			var dataLength = data.length;
			var inGroupCaseDepGroupDistributeCnt = [];
			for(var i = 0;i<data.length&&i<9;i++)
			{
				inGroupCaseDepGroupDistributeCnt.push({name:data[i].name,value:data[i].cnt});
			}
			if(dataLength>9)
			{
				var otherCnt = 0;
				for(var i = 9;i<dataLength;i++)
				{
					otherCnt = otherCnt+data[i].cnt;
				}
				inGroupCaseDepGroupDistributeCnt.push({name:'其他',value:otherCnt});
			}
			pieCharts($('#'+tabId+' #inGroupCaseDepGroupDistributeChart'), inGroupCaseDepGroupDistributeCnt, piece+'分布图', '');
		});
}
/**
 * mdc下病例信息
 * @param monitorType  =>depGroup dep ward clinic
 * @param layer  =>hsp depGroup dep ward
 */
function mdcCaseInfo(monitorType,layer)
{
	$.post(contextPath+'/CaseAnalysis/mdcGroupInGroupCase.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			str+='	<table id="mdcGroupDistributeTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">MDC代码</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">MDC描述</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #mdcGroupDistributeTable').html(str);
			var columns = [
			               {"data": 'code'},
			               {"data": 'name',"sWidth":400},
			               {"data": 'cnt'},
			               {
			            	   "data": 'operation',
			            	   "render": function(obj, type, full){
			            		   return "<a href = \"javascript:mdcCaseInfoDistribute('"+layer+"','"+full.code+"')\"><i class='fa fa-pie-chart' aria-hidden='true' title = '分布'></i></a>";
		            		   }
			               }];
			var data = result.data;
			$("#"+tabId+" #mdcGroupDistributeTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 2,3,{id:['mdcGroupDistributeChart'],nameCode:'code',field:['cnt'],title:['各MDC病例数分布及占比图'],ignore:false});
		});
}
/**
 * mdc 病例分布图
 * @param monitorType
 * @param mdcCode
 */
function mdcCaseInfoDistribute(monitorType,mdcCode)
{
	var title = getTitle(monitorType);
	$.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
		var dialog  = $(data);
		dialog.find(".modal-title").html("MDC"+title+"病例分布");
		dialog.modal({
			keyboard: false
		}).on({
			'hidden.bs.modal' : function(){
				$(this).remove();
			},
			'shown.bs.modal' : function(){
				dialog.find(".modal-body").empty();
				dialog.find(".modal-dialog").width(1200);
				var tmpStr = "";
				tmpStr += "<div class='col-xs-12'>";
				tmpStr += "	<div class='col-xs-6' id = 'mdcDepGroupDistributeChart' style='width: 550px; height: 300px'>";
				tmpStr += "	</div>";
				tmpStr += "	<div class='col-xs-6' id = 'mdcDepGroupDistributeTable'>";
				tmpStr += "	</div>";
				tmpStr += "</div>";
				dialog.find(".modal-body").css("height","450px");
				dialog.find(".modal-body").append(tmpStr);
				
				$.post(contextPath+'/CaseAnalysis/mdcDepGroupDistributeChart.dhc',
				{
					'monitorType':monitorType,
					'type1':paramTabPage[tabId].previous,
					'pardepgroupCode':paramTabPage[tabId].depGroupCode,
					'pardepCode':paramTabPage[tabId].depCode,
					'parwardCode':paramTabPage[tabId].wardCode,
					'parmdcCode':mdcCode,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
				}).done(function(result){
					var str="";
					str+='	<table id="mdcDepGroupDistributeTable-sub" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
					str+='		<thead> ';
					str+='			<tr role="row"> ';
					str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+title+'</th> ';
					str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病例数</th> ';
					str+='			</tr> ';
					str+='		</thead> ';
					str+='		<tbody></tbody> ';
					str+='	</table> ';
					dialog.find(".modal-body #mdcDepGroupDistributeTable").html(str);
					var columns = [
					               {"data": 'name'},
					               {
					            	   "data": 'cnt',
					            	   "render": function(obj, type, full)
					            	   {

				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:caseData('"+monitorType+"','ingroup','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"','"+mdcCode+"')\">"+full.cnt+"</a>";
				            		   }
				            	   }
					               ];
					var data = result.data;
					dialog.find(".modal-body #mdcDepGroupDistributeTable-sub").caseAnalysisDataTable(columns, data, 1, 0, 0, 0,0);
					
					var dataLength = data.length;
					var mdcDepGroupDistributeCnt = [];
					for(var i = 0;i<dataLength&&i<9;i++)
					{
						mdcDepGroupDistributeCnt.push({name:data[i].name,value:data[i].cnt});
					}
					pieCharts(dialog.find(".modal-body #mdcDepGroupDistributeChart"), mdcDepGroupDistributeCnt, mdcCode+'前十分布图', '');
				});
			}
		});
 });
}
/**
 * 各层未入组病例
 */
function caseNotInGroupLayer(monitorType)
{
	var title = getTitle(monitorType);
	//这块数据与上面数据有重复 直接调用
	$.post(contextPath+'/CaseAnalysis/loadOutCaseTypeInfo.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var data = result.data;
			var l = data.length;
			var str="";
			str+='	<table id="depGroupNotInPercentTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">未入组病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">未入组占比(%)</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #depGroupNotInPercentTable').html(str);
			var columns = [
			               {"data": 'name1',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
		            	   {"data": 'notincasecnt'},
			               {"data": 'allcnt'},
			               {"data": 'notInRatio'},
			               {"data": 'operation',
			            	   "render": function(obj, type, full){

			            		   if(obj.iDataRow==l-1){
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
			            			   switch(paramTabPage[tabId].monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = paramTabPage[tabId].depGroupCode;
			            				   break;
			            			   case "dep":
			            				   dep = paramTabPage[tabId].depCode;
			            				   break;
			            			   case "ward":
			            				   ward = paramTabPage[tabId].wardCode;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:caseNotInGroupLayerTrend('"+paramTabPage[tabId].previous+"','"+depgroup+"','"+dep+"','"+ward+"','','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
			            		   }
			            		   else
		            			   {
			            			   var depgroup = "";
			            			   var dep = "";
		            				   var ward = "";
		            				   var clinic = "";
			            			   switch(monitorType)
			            			   {
			            			   case "depGroup":
			            				   depgroup = full.code;
			            				   break;
			            			   case "dep":
			            				   dep = full.code;
			            				   break;
			            			   case "ward":
			            				   ward = full.code;
			            				   break;
			            			   case "clinic":
			            				   if(paramTabPage[tabId].previous=='dep')
		            					   {
			            					   dep = paramTabPage[tabId].depCode;
		            					   }
			            				   else
		            					   {
			            					   ward = paramTabPage[tabId].wardCode;
		            					   }
			            				   clinic = full.code;
			            				   break;
			            			   }
			            			   return "<a href = \"javascript:caseNotInGroupLayerTrend('"+monitorType+"','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"','"+full.name+"')\"><i class='fa fa-line-chart' aria-hidden='true' title = '趋势'></i></a>";
		            			   }
		            		   }
		            	   }
			               ];
			
			$("#"+tabId+" #depGroupNotInPercentTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 2,4);
		});

}
/**
 * 各层未入组病例趋势
 */
function caseNotInGroupLayerTrend(monitorType,depGroup,dep,ward,clinic,name)
{
	 $.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html(name+"未入组病例趋势图");
			dialog.modal({
				keyboard: false
			}).on({
				'hidden.bs.modal' : function(){
					$(this).remove();
				},
				'shown.bs.modal' : function(){
					dialog.find(".modal-body").empty();
					var trendStr = "";
					trendStr += "	<div class='tab-content'>";
					trendStr += "		<div role='tabpanel' class='tab-pane active'>";
					trendStr += "			<ul class='nav nav-tabs tabtrend' role='tablist'>";
					trendStr += "				<li role='presentation' class='active'><a href='#notInGroup_Trend_M' role='tab' data-toggle='tab'>月度</a></li>";
					trendStr += "				<li role='presentation'><a href='#notInGroup_Trend_Y' role='tab' data-toggle='tab'>年度</a></li>";
					trendStr += "			</ul>";
					trendStr += "			<div class='tab-content'>";
					trendStr += "				<div role='tabpanel' class='tab-pane active' id='notInGroup_Trend_M'>";
					trendStr += "					<div id='notInGroup_Trend_M_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "				<div role='tabpanel' class='tab-pane' id='notInGroup_Trend_Y'>";
					trendStr += "					<div id='notInGroup_Trend_Y_Chart' style='width: 800px; height: 400px'><img src='images/pageloading.gif'></div>";
					trendStr += "				</div>";
					trendStr += "			</div>";
					trendStr += "		</div>";
					trendStr += "	</div>";
					dialog.find(".modal-body").append(trendStr);
					var dateFrom = $('#'+tabId+' input#startDate').val();
					var dateTo = $('#'+tabId+' input#endDate').val();
					//未入组病例数趋势图
					$.post(contextPath+'/CaseAnalysis/mrDataItemTrend.dhc',{
					'monitorType':monitorType,
					'type1':'notin',
					'type2':paramTabPage[tabId].previous,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'pargroupName':clinic,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){
						var year = dateFrom.substr(0,4);
						var notInCntlines = [];
						var notInCntlineT = {"code": "QuotaValue", "desc": year+"年", "data":[]};
						var notInCntlineL = {"code": "QuotaValue", "desc": (year-1)+"年", "data":[]};
						notInCntlines.push(notInCntlineT);
						notInCntlines.push(notInCntlineL);
						
						//病例数
						var notInCntdatas = [];
						notInCntdatas.push(result.data.monthCntT);
						notInCntdatas.push(result.data.monthCntL);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #notInGroup_Trend_M_Chart"), notInCntlines, notInCntdatas, "未入组病例数趋势图-月度",'',chartParams);
						
						var notInCntlines_Y = [{"code": "QuotaValue", "desc": "年度", "data":[]}];
						var notInCntdatas_Y = [];
						notInCntdatas_Y.push(result.data.yearCnt);
						var chartParams={legendPosition:'bottom'}
						lineChartBasic(dialog.find(".modal-body #notInGroup_Trend_Y_Chart"), notInCntlines_Y, notInCntdatas_Y, "未入组病例数趋势图-年度",'',chartParams);
					});
				}
			});
	 });
}
/**
 * 各层未入组原因
 * @param monitorType
 */
function caseNotInGroupReason(monitorType)
{
	var title = getTitle(monitorType);
	$.post(contextPath+'/CaseAnalysis/depGroupNotInReason.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			var data = result.data;
			var l= data.length;
			str+='	<table id="depGroupNotInReasonTable-CaseAnalysis" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+title+'</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">手术/操作与诊断不符</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">费用/住院日异常</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">缺少主要诊断</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要诊断有误</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主诊断规范问题或新生儿年龄/体重问题</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">其他</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #depGroupNotInReasonTable').html(str);
			var columns = [
			               {"data": 'name',
			            	   "render": function(obj, type, full){
			            		   if(obj.iDataRow==l-1){
			            			   return full.name;
			            		   }
			            		   else
		            			   {
			            			   if(toNextLayerBool(monitorType))
		            				   {
			            				   return "<a href = \"javascript:toNextLayerCaseAnalysis('"+monitorType+"','"+full.code+"','"+full.name+"')\">"+full.name+"</a>";
			            			   }
			            			   else
		            				   {
			            				   return full.name;
		            				   }
		            			   }
		            		   }
		            	   },
		            	   {
			            	   "data": 'diag_n_m_oper',
			            	   "render": function(obj, type, full){
			            		   if(full.diag_n_m_oper>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','1','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.diag_n_m_oper+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','1','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.diag_n_m_oper+"</a>";
			            			   }
		            			   }
			            		   return  full.diag_n_m_oper ;
                  				 }
			               },
			               {
			            	   "data": 'fee_day_err',
			            	   "render": function(obj, type, full){
			            		   if(full.fee_day_err>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','2','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.fee_day_err+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','2','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.fee_day_err+"</a>";
			            			   }
		            			   }
			            		   return  full.fee_day_err ;
                  				 }
			               },
			               {
			            	   "data": 'lessdiag',
			            	   "render": function(obj, type, full){
			            		   if(full.lessdiag>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','3','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.lessdiag+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','3','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.lessdiag+"</a>";
			            			   }
		            			   }
			            		   return  full.lessdiag ;
                  				 }
			               },
			               {
			            	   "data": 'diagerr',
			            	   "render": function(obj, type, full){
			            		   if(full.diagerr>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','4','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.diagerr+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','4','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.diagerr+"</a>";
			            			   }
		            			   }
			            		   return  full.diagerr ;
                  				 }
			               },
			               {
			            	   "data": 'babyerr',
			            	   "render": function(obj, type, full){
			            		   if(full.babyerr>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','5','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.babyerr+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','5','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.babyerr+"</a>";
			            			   }
		            			   }
			            		   return  full.babyerr ;
                  				 }
			               },
			               {
			            	   "data": 'other',
			            	   "render": function(obj, type, full){
			            		   if(full.other>0)
		            			   {
				            		   if(obj.iDataRow==l-1)
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
				            			   switch(paramTabPage[tabId].monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = paramTabPage[tabId].depGroupCode;
				            				   break;
				            			   case "dep":
				            				   dep = paramTabPage[tabId].depCode;
				            				   break;
				            			   case "ward":
				            				   ward = paramTabPage[tabId].wardCode;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+paramTabPage[tabId].previous+"','6','"+depgroup+"','"+dep+"','"+ward+"','')\">"+full.other+"</a>";
			            			   }
				            		   else
			            			   {
				            			   var depgroup = "";
				            			   var dep = "";
			            				   var ward = "";
			            				   var clinic = "";
				            			   switch(monitorType)
				            			   {
				            			   case "depGroup":
				            				   depgroup = full.code;
				            				   break;
				            			   case "dep":
				            				   dep = full.code;
				            				   break;
				            			   case "ward":
				            				   ward = full.code;
				            				   break;
				            			   case "clinic":
				            				   if(paramTabPage[tabId].previous=='dep')
			            					   {
				            					   dep = paramTabPage[tabId].depCode;
			            					   }
				            				   else
			            					   {
				            					   ward = paramTabPage[tabId].wardCode;
			            					   }
				            				   clinic = full.code;
				            				   break;
				            			   }
				            			   return "<a href = \"javascript:notInCaseData('"+monitorType+"','6','"+depgroup+"','"+dep+"','"+ward+"','"+clinic+"')\">"+full.other+"</a>";
			            			   }
		            			   }
			            		   return  full.other ;
                  				 }
			               }
			               ];
			
			$("#"+tabId+" #depGroupNotInReasonTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 1, 1,0);
		});
}
/**
 * 未入组病例的主要诊断信息
 * @param monitorType
 * @param previous
 */
function notIngroupMainDiag(monitorType,previous)
{
	$.post(contextPath+'/CaseAnalysis/notIngroupMainDiagAnalysis.dhc',{
		'monitorType':monitorType,
		'pardepgroupCode':paramTabPage[tabId].depGroupCode,
		'pardepCode':paramTabPage[tabId].depCode,
		'parwardCode':paramTabPage[tabId].wardCode,
		'type1':paramTabPage[tabId].previous,//指示上一个层级
		'dateFrom':paramTabPage[tabId].dateFrom,
		'dateTo':paramTabPage[tabId].dateTo
		}).done(function(result){
			var str="";
			str+='	<table id="notInGroupDiagnosisAnalysisTable-CaseAnalysis" border = "1" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
			str+='		<thead> ';
			str+='			<tr role="row"> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要诊断类目代码</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病例数</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">类目名称</th> ';
			str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要ICD编码</th> ';
			str+='			</tr> ';
			str+='		</thead> ';
			str+='		<tbody></tbody> ';
			str+='	</table> ';
			$('#'+tabId+' #notInGroupDiagnosisAnalysisTable').html(str);
			var columns = [
			               {"data": 'code'},
			               {"data": 'cnt',
			            	   "render": function(obj, type, full){
			            		   var depgroup = "";
		            			   var dep = "";
	            				   var ward = "";
			            		   switch(previous)
		            			   {
		            			   case "depGroup":
		            				   depgroup = paramTabPage[tabId].depGroupCode;
		            				   break;
		            			   case "dep":
		            				   dep = paramTabPage[tabId].depCode;
		            				   break;
		            			   case "ward":
		            				   ward = paramTabPage[tabId].wardCode;
		            				   break;
		            			   }
		            			   return "<a href = \"javascript:mainDiagnoseCaseList('"+previous+"','"+depgroup+"','"+dep+"','"+ward+"','"+full.code+"')\">"+full.cnt+"</a>";
		            		   }
			               },
		            	   {"data": 'name'},
		            	   {"data": 'diagcode'}
			               ];
			var data = result.data;
			$("#"+tabId+" #notInGroupDiagnosisAnalysisTable-CaseAnalysis").caseAnalysisDataTable(columns, data, 1, 0, 0, 0,0,{mergeCol:[0,1,2]});
		});
}
/**
 * 未入组病例主要诊断模块  对应的病例列表
 * @param monitorType
 * @param depGroup
 * @param dep
 * @param ward
 * @param icdCode
 */
function mainDiagnoseCaseList(monitorType,depGroup,dep,ward,icdCode)
{
	 $.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html("有主要诊断未入组病例明细表");
			dialog.modal({
				keyboard: false
			}).on({
				'hidden.bs.modal' : function(){
					$(this).remove();
				},
				'shown.bs.modal' : function(){
					dialog.find(".modal-body").empty();
					dialog.find(".modal-body").append("<div id = 'mainDiagnoseCaseTable'></div>");
					//有主要诊断未入组病例明细表
					$.post(contextPath+'/CaseAnalysis/mainDiagnoseCase.dhc',{
					'type1':monitorType,
					'pardepgroupCode':depGroup,
					'pardepCode':dep,
					'parwardCode':ward,
					'type2':icdCode,
					'dateFrom':paramTabPage[tabId].dateFrom,
					'dateTo':paramTabPage[tabId].dateTo
					}).done(function(result){

						var str="";
						str+='	<table id="mainDiagnoseCaseTable-list" class="display dataTable" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
						str+='		<thead> ';
						str+='			<tr role="row"> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">病案号</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">姓名</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">性别</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">年龄</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要诊断</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">其他诊断</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">主要手术</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">其他手术</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院科室组</th> ';
						str+='				<th tabindex="0" aria-controls="example" rowspan="1" colspan="1">出院科室</th> ';
						str+='			</tr> ';
						str+='		</thead> ';
						str+='		<tbody></tbody> ';
						str+='	</table> ';
						dialog.find(".modal-body #mainDiagnoseCaseTable").html(str);
						var columns = [
						               {
						            	   "data": 'mrNo',
						            	   "render": function(obj, type, full)
						            	   {
						            		   var mrNo = full.mrNo;
						            		   return "<a href=\"javascript:caseAnlysisPatientInfo('"+full.id+"','"+full.patientName+"')\">"+mrNo+"</a>";
					            		   }
						               },
						               {"data": 'patientName'},
						               {"data": 'sex'},
						               {"data": 'ageYear'},
						               {"data": 'mainDiagDesc'},
						               {"data": 'otherDiag'},
						               {"data": 'mainOperDesc'},
						               {"data": 'otherOper'},
						               {"data": 'depGroupName'},
						               {"data": 'depName'}
						               ];
						var data = result.data;
						dialog.find(".modal-body #mainDiagnoseCaseTable-list").caseAnalysisDataTable(columns, data, 1, 0, 0, 0,0);
					});
				}
			});
	 });
	
}
function caseAnlysisPatientInfo(patientId,patientName){
	$("#modalcq .close").click();
	openTab('/pages/yizheng/qcPatientList.jsp',patientName+'|病案首页', 'mainDiagnoseCaselist'+patientId,'mainDiagnoseCaselist'+patientId,{patientId:patientId});
}


